angular.module('wf-utils')
.directive('morrisLine', ()->
    restrict: 'EA',
    template: '<div></div>',
    scope: {
        data: '=',
        xkey: '=',
        ykey: '='
        xlabel:'='
        },
    link: (scope,element,attrs)->
            new Morris.Line({
                element: element,
                data: scope.data,
                xkey: scope.xkey,
                ykeys: [scope.ykey]
                labels:["销售额"]
            })
)
angular.module('wf-utils')
.directive("wfMorrisChart",()->
    restrict:"EA",
    template: '<div></div>',
    scope:{
        data:"=",
        type:"=",
        options:"="
    },
    link:(scope,ele,attrs)->
        console.log("123123",scope.type)
        data=scope.data
        type=scope.type
        options=undefined
        switch type
            when "line"
                options=angular.extend({element:ele[0],data:data},scope.options)
                new Morris.Line(options)
            when "area"
                options=angular.extend({element:ele[0],data:data},scope.options)
                new Morris.Area(options)
            when "bar"
                options=angular.extend({element:ele[0],data:data},scope.options)
                new Morris.Bar(options)
)